package com.example.commentservice.service;

import com.example.commentservice.dao.CommentDao;
import com.example.commonapi.pojo.Comment;
import com.example.commonapi.pojo.UAC;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Service(version = "${demo.service.version}")
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentDao commentDao;

    public void setCommentDao(CommentDao commentDao) {
        this.commentDao = commentDao;
    }

    public int addComment(Comment comment) {
        return commentDao.addComment(comment);
    }

    public List<Comment> getCommentByTopicId(Integer topicId) {
        return commentDao.getCommentByTopicId(topicId);
    }

    public void deleteComment(int id) {
        commentDao.deleteComment(id);
    }

    public void deleteCommentByTopicId(int topicId) {
        commentDao.deleteCommentByTopicId(topicId);
    }

    public List<UAC> getUACByTopicId(Integer topicId) {
        return commentDao.getUACByTopicId(topicId);
    }

    public List<UAC> getUACByUserId(Integer userId) {
        return commentDao.getUACByUserId(userId);
    }

    public Comment getCommentById(Integer id) {
        return commentDao.getCommentById(id);
    }

    public void updateComment(Comment comment) {
        commentDao.updateComment(comment);
    }

    public void deleteCommentByUserId(Integer userId) {
        commentDao.deleteCommentByUserId(userId);
        System.out.println("删除了 userId="+userId + "的评论");
    }


}
